//
//  DHS2_ProductInfo_WebCell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/21.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHS2_ProductInfo_WebCell.h"

@interface DHS2_ProductInfo_WebCell()<UIWebViewDelegate>

@property (weak, nonatomic) IBOutlet UIWebView *webView;

@end

@implementation DHS2_ProductInfo_WebCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.webView.delegate = self;
}

- (void)updateCell:(NSDictionary *)dic{
    NSString *htmlString = [NSString stringWithFormat:@"<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\"><meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\"><meta name=\"referrer\" content=\"never\"><style>img {width: 100%;}</style></head><body>%@</body></html>",[dic objectForKey:@"description"]];
    [self.webView loadHTMLString:htmlString baseURL:nil];
}

#pragma mark - UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    CGFloat webViewHeight = webView.scrollView.contentSize.height;
    NSLog(@"webViewHeight:::%f",webViewHeight);
    NSLog(@"webViewHeight:::%@",[NSNumber numberWithFloat:webViewHeight]);
    [self routerEventWithName:@"product_info_webViewDidFinishLoad" userInfo:@{@"height":[NSNumber numberWithFloat:webViewHeight]}];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
